#include <boost/lexical_cast.hpp>
#include "Reply.h"
#include "SMTPDefaults.h"

using namespace kc_sf;

// ------------------------------------------------ //

Reply::Reply()
: Code( 0 )
{
}

// ------------------------------------------------ //

Reply::Reply( int code )
: Code( code )
{
}

// ------------------------------------------------ //

Reply::Reply( int code, std::string text )
: Code( code ),
  TextLines( 1, text )
{
}

// ------------------------------------------------ //

Reply::Reply( int code, const TextLinesCollection &text )
: Code( code ),
  TextLines( text.begin(), text.end() )
{
}

// ------------------------------------------------ //

std::string Reply::toString() const
{
    std::string ret;

    std::string code = boost::lexical_cast<std::string>( Code );

	for( size_t i = 0; i < TextLines.size(); ++i )
	{
		ret += code;
		ret += ( i == TextLines.size() - 1 ) ? " " : "-";
		ret += TextLines[i];
		ret += CRLF;
	}

    return ret;
}
